﻿using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;

public class ResTipsView : MonoBehaviour
{

    public GameObject SunIcon;
    public GameObject ShitIcon;
    public Text Tips;

    private GameObject _useIcon;

    public void Init(int resChange, bool isShit)
    {
        _useIcon = isShit ? ShitIcon : SunIcon;
        _useIcon.SetActive(true);
        Tips.text = resChange > 0 ? "+" + resChange : resChange.ToString();
    }

    void OnEnable()
    {
        transform.DOLocalMoveY(transform.localPosition.y + 50, 0.5f);
        _useIcon.GetComponent<Image>().DOFade(0, 1.5f);
        Tips.DOFade(0, 1.5f).OnComplete(() =>
        {
            Destroy(gameObject);
        });
    }
}
